//按时间计算预约费用
var MathUtil = Java.type('com.kunlong.util.MathUtil');
var math = MathUtil.getInstance();
/**
 * 预约按时长计费
 * @param {计} params
 * @param {*} r
 */
function cal(billParam,billResult,ruleParams){
    var p = JSON.parse(ruleParams);
    var freeMinutes = p.freeMinutes||0;//免费时间
    var dayMaxAmount = p.dayMaxAmount||0;//封顶费用
    var standardAmount = p.standardAmount||1;//标准费用（元)
    var standardUnit = p.standardUnit||1;//标准单位(分)

    var seconds = billParam.getEndTime().getTime()-billParam.getStartTime().getTime();
    var minutes = Math.ceil(seconds/60000);
    if(freeMinutes !=null && freeMinutes>0){ //如果有设置免费时间
        if(minutes<=freeMinutes){
            billResult.setAmount(math.toBigDecimal(0));
            return ;
        }
    }
    var num = Math.ceil(minutes/standardUnit);
    billResult.setAmount(math.multiply(standardAmount,math.toBigDecimal(num)));
}